import request from "@/utils/request";
import { AesMain } from "@/utils/AesHmacMD5"

// 校验模板编码的唯一性
export function unique(query) {
  return request({
    url: "/admin/budget/form/unique/",
    method: "post",
    data: AesMain(query)
  });
}


// excel 录入保存信息
export function addEnter(enterForm) {
  return request({
    url: "/admin/budget/enter/addEnter/",
    method: "post",
    data: AesMain(enterForm)
  });
}

// excel 查看录入信息
export function enterListType(enterForm) {
  return request({
    url: "/admin/budget/enter/enterListType/",
    method: "post",
    data: AesMain(enterForm)
  });
}

// excel 录取-------------下载
export function downloadEnterdata(enterForm) {
  return request({
    url: "/admin/budget/enter/downloadEnterdata/",
    method: "post",
    data: AesMain(enterForm)
  });
}
// 删除enter列表
export function delEnterType(query) {
  return request({
    url: "/admin/budget/enter/delEnterType/",
    method: "post",
    data: AesMain(query)
  });
}

// 删除模板列表
export function treeByFormId(formId) {
  return request({
    url: "/admin/budget/form/treeByFormId/" + formId + "/",
    method: "get"
  });
}

// ================================================================================
// ================================================================================
// ================================================================================

// 查询台账列表
export function listType(query) {
  return request({
    url: "/admin/budget/ledger/list/",
    method: "post",
    data: AesMain(query)
  });
}
// 查询台账总列表
export function listTypeAll(query) {
  return request({
    url: "/admin/budget/ledger/listall/",
    method: "post",
    data: AesMain(query)
  });
}
// 查询台账单项列表
export function listTypeSingle(query) {
  return request({
    url: "/admin/budget/ledger/listsingle/",
    method: "post",
    data: AesMain(query)
  });
}
// 查询台账单项列表
export function listBywellname(query) {
  return request({
    url: "/admin/budget/costdetail/listBywellname/",
    method: "post",
    data: AesMain(query)
  });
}
// 校验模板表头数据是否重复---针对于整个表头数据
export function inspectHeaderAll(query) {
  return request({
    url: "/admin/budget/form/inspectHeaderAll/",
    method: "post",
    data: AesMain(query)
  });
}

// 新增模板列表
export function addType(query) {
  return request({
    url: "/admin/budget/ledger/add/",
    method: "post",
    data: AesMain(query)
  });
}


// 新增区域列表
export function addRegionType(query) {
  return request({
    url: "/admin/budget/region/add/",
    method: "post",
    data: AesMain(query)
  });
}

// 根据ID回显模板数据
export function dataEche(query) {
  return request({
    url: "/admin/budget/form/dataEche/",
    method: "post",
    data: AesMain(query)
  });
}

// 修改模板列表
export function editType(query) {
  return request({
    url: "/admin/budget/form/edit/",
    method: "post",
    data: AesMain(query)
  });
}

// 删除数字台账
export function delType(query) {
  debugger
  return request({
    url: "/admin/budget/ledger/delete/",
    method: "post",
    data: AesMain(query)
  });
}

// 模板转字典类型
export function modelToDict() {
  return request({
    url: "/admin/budget/form/modelToDict/",
    method: "post",
    data: AesMain()
  });
}


export function listTypeDetail(query) {
  return request({
    url: "/admin/budget/costdetail/list/",
    method: "post",
    data: AesMain(query)
  });
}
export function listTypeDetailByTime(query) {
  return request({
    url: "/admin/budget/costdetail/listByTime/",
    method: "post",
    data: AesMain(query)
  });
}

// 新增费用
export function addTypeCost(query) {
  return request({
    url: "/admin/budget/cost/add/",
    method: "post",
    data: AesMain(query)
  });
}

//新增单条数字台账数据
export function addLedger(query) {
  return request({
    url: "/admin/budget/ledger/addLedger/",
    method: "post",
    data: AesMain(query)
  });
}

//修改台账信息
export function editLedger(query) {
  return request({
    url: "/admin/budget/ledger/edit/",
    method: "post",
    data: AesMain(query)
  });
}

// 查询公司列表
export function listCompanyType(query) {
  return request({
    url: "/admin/budget/company/list/",
    method: "post",
    data: AesMain(query)
  });
}

// 删除费用
export function delCostType(query) {
  return request({
    url: "/admin/budget/cost/delete/",
    method: "post",
    data: AesMain(query)
  });
}


//修改费用信息
export function editCost(query) {
  return request({
    url: "/admin/budget/cost/edit/",
    method: "post",
    data: AesMain(query)
  });
}

//获取数据台账信息
export function draw_wellDrilling(query) {
  return request({
    url: "/admin/budget/ledger/ledgerWellList/",
    method: "post",
    data: AesMain(query)
  });
}
//获取数据台账信息
export function downloadLedger(query) {
  return request({
    url: "/admin/budget/ledger/downloadLedger/",
    method: "post",
    data: AesMain(query)
  });
}
//获取数据台账同期数据信息
export function getTermData(query) {
  return request({
    url: "/admin/budget/ledger/getTermData/",
    method: "post",
    data: AesMain(query)
  });
}
//获取数据台账工作量及投资完成情况分析数据信息
export function getWorkList(query) {
  return request({
    url: "/admin/budget/ledger/getWorkList/",
    method: "post",
    data: AesMain(query)
  });
}
//批量复制数字台账
export function copyLedgerData(query) {
  return request({
    url: "/admin/budget/ledger/copyLedgerData/",
    method: "post",
    data: AesMain(query)
  });
}


//ledger/getDictList查询所有区域 凹陷 井号
export function getDictList(query) {
  return request({
    url: "/admin/budget/ledger/getDictList/",
    method: "post",
    data: AesMain(query)
  });
}

//深复制
export function deepCopy (obj) {
  // 只拷贝对象
  if (typeof obj !== 'object') return;
  // 根据obj的类型判断是新建一个数组还是一个对象
  var newObj = obj instanceof Array ? [] : {};
  for (var key in obj) {
    // 遍历obj,并且判断是obj的属性才拷贝
    if (obj.hasOwnProperty(key)) {
      // 判断属性值的类型，如果是对象递归调用深拷贝
      newObj[key] = typeof obj[key] === 'object' ? deepCopy(obj[key]) : obj[key];
    }
  }
  return newObj;
}

